﻿namespace TestTool.GUI.Controls
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Net;
    using System.Net.Sockets;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Windows.Forms;
    using TestTool.GUI.Controllers;
    using TestTool.GUI.Enums;
    using TestTool.GUI.Utils;
    using TestTool.GUI.Views;
    using TestTool.Proxies.Onvif;
    using TestTool.Tests.Definitions.Interfaces;
    using TestTool.Tests.Definitions.UI;
    using System.Linq;

    internal class SettingsControl : Page, ITestSettingsView, IView
    {
        private Control[] _controlsList;
        private TestTool.GUI.Enums.ApplicationState _currentState;
        private bool _isTextChangedHandlerRunning;
        private string _lastValidIpv4Dns;
        private string _lastValidIpv4Gateway;
        private string _lastValidIpv4Ntp;
        private string _lastValidIpv6Dns;
        private string _lastValidIpv6Gateway;
        private string _lastValidIpv6Ntp;
        private int _lastValidMessageTimeout;
        private int _lastValidOperationDelay;
        private int _lastValidRebootTimeout;
        private int _lastValidRelayOutputDelayMonostable;
        private int _lastValidSafetyDelay;
        private int _lastValidSearchTimeout;
        private int _lastValidSubscriptionTimeout;
        private int _lastValidTimeBetweenTests;
        private Dictionary<string, SettingsTabPage> _pages;
        private string _password1;
        private string _password2;
        private Button btnGetPTZNodes;
        private Button btnGetRecordings;
        private Button btnGetTopics;
        private Button btnGetVideoSources;
        private Button btnValidate;
        private ComboBox cmbEventTopic;
        private ComboBox cmbPTZNodes;
        private ComboBox cmbRecordingToken;
        private ComboBox cmbSecureMethod;
        private ComboBox cmbVideoSource;
        private IContainer components;
        private GroupBox gbEnvironment;
        private GroupBox gbMisc;
        private GroupBox gbTimeouts;
        private Label label2;
        private Label lblDNS;
        private Label lblDnsIpv4;
        private Label lblDnsIpv6;
        private Label lblEventTopic;
        private Label lblGateWay;
        private Label lblGatewayIpv4;
        private Label lblGatewayIpv6;
        private Label lblMessageTimeout;
        private Label lblMetadataFilter;
        private Label lblNamespaces;
        private Label lblNTP;
        private Label lblNtpIpv4;
        private Label lblNtpIpv6;
        private Label lblOperationDelay;
        private Label lblPasswords;
        private Label lblPtzNode;
        private Label lblQueryTimeout;
        private Label lblRebootTime;
        private Label lblRecordingToken;
        private Label lblRelayOutputsDelay;
        private Label lblRetentionTimeout;
        private Label lblSafetyDelay;
        private Label lblSubscriptionTimeout;
        private Label lblTimeBetweenTests;
        private Label lblVideoSource;
        private RadioButton rbEmbeddedPasswords;
        private RadioButton rbOwnPasswords;
        private TextBox tbDnsIp4;
        private TextBox tbDnsIp6;
        private TextBox tbGatewayIpv4;
        private TextBox tbGatewayIpv6;
        private TextBox tbMessageTimeout;
        private RichTextBox tbMetadataFilter;
        private TextBox tbNamespaces;
        private TextBox tbNtpIp4;
        private TextBox tbNtpIp6;
        private TextBox tbOperationDelay;
        private TextBox tbPassword1;
        private TextBox tbPassword2;
        private TextBox tbRebootTimeout;
        private TextBox tbRelayOutputsDelayMonostable;
        private TextBox tbRetentionTime;
        private TextBox tbSafetyDelay;
        private TextBox tbSubscriptionTimeout;
        private TextBox tbTimeBetweenTests;
        private TextBox tbTimeout;
        private TabControl tcMiscSettings;
        private ToolTip toolTipSettings;
        private TabPage tpEvents;
        private TabPage tpIO;
        private TabPage tpPTZ;
        private TabPage tpRecordingSearch;
        private TabPage tpSecurity;

        public event EventHandler GetEventTopics;

        public event EventHandler GetPTZNodes;

        public event EventHandler GetRecordings;

        public event EventHandler GetVideoSources;

        public SettingsControl()
        {
            this.InitializeComponent();
        }

        public void AddSettingsPages(List<SettingsTabPage> pages)
        {
            this._pages = new Dictionary<string, SettingsTabPage>();
            foreach (SettingsTabPage page in from P in pages
                                             orderby P.Order
                                             select P)
            {
                TabPage page2 = new TabPage(page.PageName)
                {
                    Name = page.ParametersType.GUID.ToString()
                };
                page2.Controls.Add(page);
                this.tcMiscSettings.TabPages.Add(page2);
                this._pages.Add(page.ParametersType.GUID.ToString(), page);
            }
        }

        private void btnGetPTZNodes_Click(object sender, EventArgs e)
        {
            if (this.GetPTZNodes != null)
            {
                this.GetPTZNodes(this, e);
            }
        }

        private void btnGetRecordings_Click(object sender, EventArgs e)
        {
            if (this.GetRecordings != null)
            {
                this.GetRecordings(this, e);
            }
        }

        private void btnGetTopics_Click(object sender, EventArgs e)
        {
            if (this.GetEventTopics != null)
            {
                this.GetEventTopics(this, e);
            }
        }

        private void btnGetVideoSources_Click(object sender, EventArgs e)
        {
            if (this.GetVideoSources != null)
            {
                this.GetVideoSources(this, e);
            }
        }

        private void btnValidate_Click(object sender, EventArgs e)
        {
            FilterValidationInfo info = FilterValidation.Validatefilter(this.tbMetadataFilter.Text);
            if (!info.Valid)
            {
                StringBuilder builder = new StringBuilder("Filter expression is not correct" + Environment.NewLine);
                if (!string.IsNullOrEmpty(info.Message))
                {
                    builder.AppendLine(info.Message);
                }
                else
                {
                    this._isTextChangedHandlerRunning = true;
                    foreach (ExpressionInfo info2 in info.IncorrectExpressions)
                    {
                        builder.AppendLine(string.Format("Expression '{0}' is not valid: {1}", info2.Expression, info2.Error));
                        Color yellow = Color.Yellow;
                        this.tbMetadataFilter.SelectionStart = info2.Left;
                        this.tbMetadataFilter.SelectionLength = info2.Expression.Length;
                        this.tbMetadataFilter.SelectionBackColor = yellow;
                    }
                    this._isTextChangedHandlerRunning = false;
                }
                MessageBox.Show(builder.ToString(), "Validation failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                MessageBox.Show("Validation succeeded!", "OK");
            }
        }

        private void cmbEventTopic_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.cmbEventTopic.SelectedIndex >= 0)
            {
                EventsTopicInfo selectedItem = (EventsTopicInfo)this.cmbEventTopic.SelectedItem;
                this.tbNamespaces.Text = selectedItem.NamespacesDefinition;
            }
        }

        public void DisableControl()
        {
            base.DisableControls(this.ControlsList);
            foreach (SettingsTabPage page in this._pages.Values)
            {
                page.Disable();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public void EnableControl()
        {
            base.EnableControls(this.ControlsList);
            foreach (SettingsTabPage page in this._pages.Values)
            {
                page.Enable();
            }
        }

        public void EnablePasswords(TestTool.GUI.Enums.ApplicationState currentState)
        {
            this.tbPassword1.Enabled = !this.rbEmbeddedPasswords.Checked && (currentState == TestTool.GUI.Enums.ApplicationState.Idle);
            this.tbPassword2.Enabled = !this.rbEmbeddedPasswords.Checked && (currentState == TestTool.GUI.Enums.ApplicationState.Idle);
        }

        public override IController GetController()
        {
            return null;
        }

        private void InitializeComponent()
        {
            this.components = new Container();
            this.gbTimeouts = new GroupBox();
            this.tbSafetyDelay = new TextBox();
            this.lblSafetyDelay = new Label();
            this.tbOperationDelay = new TextBox();
            this.lblTimeBetweenTests = new Label();
            this.lblOperationDelay = new Label();
            this.tbTimeBetweenTests = new TextBox();
            this.lblRebootTime = new Label();
            this.tbRebootTimeout = new TextBox();
            this.lblMessageTimeout = new Label();
            this.tbMessageTimeout = new TextBox();
            this.gbEnvironment = new GroupBox();
            this.lblGatewayIpv6 = new Label();
            this.lblGatewayIpv4 = new Label();
            this.tbGatewayIpv6 = new TextBox();
            this.tbGatewayIpv4 = new TextBox();
            this.lblGateWay = new Label();
            this.lblNtpIpv6 = new Label();
            this.lblDnsIpv6 = new Label();
            this.lblNtpIpv4 = new Label();
            this.lblDnsIpv4 = new Label();
            this.tbNtpIp6 = new TextBox();
            this.tbDnsIp6 = new TextBox();
            this.tbNtpIp4 = new TextBox();
            this.tbDnsIp4 = new TextBox();
            this.lblNTP = new Label();
            this.lblDNS = new Label();
            this.btnGetPTZNodes = new Button();
            this.lblPtzNode = new Label();
            this.cmbPTZNodes = new ComboBox();
            this.lblPasswords = new Label();
            this.rbOwnPasswords = new RadioButton();
            this.tbPassword1 = new TextBox();
            this.rbEmbeddedPasswords = new RadioButton();
            this.tbPassword2 = new TextBox();
            this.cmbSecureMethod = new ComboBox();
            this.label2 = new Label();
            this.tbSubscriptionTimeout = new TextBox();
            this.lblSubscriptionTimeout = new Label();
            this.btnGetTopics = new Button();
            this.cmbEventTopic = new ComboBox();
            this.lblEventTopic = new Label();
            this.gbMisc = new GroupBox();
            this.tcMiscSettings = new TabControl();
            this.tpSecurity = new TabPage();
            this.tpPTZ = new TabPage();
            this.btnGetVideoSources = new Button();
            this.cmbVideoSource = new ComboBox();
            this.lblVideoSource = new Label();
            this.tpEvents = new TabPage();
            this.tbNamespaces = new TextBox();
            this.lblNamespaces = new Label();
            this.tpIO = new TabPage();
            this.tbRelayOutputsDelayMonostable = new TextBox();
            this.lblRelayOutputsDelay = new Label();
            this.tpRecordingSearch = new TabPage();
            this.tbRetentionTime = new TextBox();
            this.lblRetentionTimeout = new Label();
            this.btnValidate = new Button();
            this.tbMetadataFilter = new RichTextBox();
            this.lblMetadataFilter = new Label();
            this.tbTimeout = new TextBox();
            this.btnGetRecordings = new Button();
            this.cmbRecordingToken = new ComboBox();
            this.lblRecordingToken = new Label();
            this.lblQueryTimeout = new Label();
            this.toolTipSettings = new ToolTip(this.components);
            this.gbTimeouts.SuspendLayout();
            this.gbEnvironment.SuspendLayout();
            this.gbMisc.SuspendLayout();
            this.tcMiscSettings.SuspendLayout();
            this.tpSecurity.SuspendLayout();
            this.tpPTZ.SuspendLayout();
            this.tpEvents.SuspendLayout();
            this.tpIO.SuspendLayout();
            this.tpRecordingSearch.SuspendLayout();
            base.SuspendLayout();
            this.gbTimeouts.Controls.Add(this.tbSafetyDelay);
            this.gbTimeouts.Controls.Add(this.lblSafetyDelay);
            this.gbTimeouts.Controls.Add(this.tbOperationDelay);
            this.gbTimeouts.Controls.Add(this.lblTimeBetweenTests);
            this.gbTimeouts.Controls.Add(this.lblOperationDelay);
            this.gbTimeouts.Controls.Add(this.tbTimeBetweenTests);
            this.gbTimeouts.Controls.Add(this.lblRebootTime);
            this.gbTimeouts.Controls.Add(this.tbRebootTimeout);
            this.gbTimeouts.Controls.Add(this.lblMessageTimeout);
            this.gbTimeouts.Controls.Add(this.tbMessageTimeout);
            this.gbTimeouts.Dock = DockStyle.Top;
            this.gbTimeouts.Location = new Point(0, 0);
            this.gbTimeouts.Name = "gbTimeouts";
            this.gbTimeouts.Size = new Size(410, 0x93);
            this.gbTimeouts.TabIndex = 7;
            this.gbTimeouts.TabStop = false;
            this.gbTimeouts.Text = "Timeouts";
            this.tbSafetyDelay.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbSafetyDelay.Location = new Point(0xa1, 0x77);
            this.tbSafetyDelay.MaximumSize = new Size(0x112, 20);
            this.tbSafetyDelay.Name = "tbSafetyDelay";
            this.tbSafetyDelay.Size = new Size(0xe8, 20);
            this.tbSafetyDelay.TabIndex = 0x20;
            this.toolTipSettings.SetToolTip(this.tbSafetyDelay, "Amount of time the Tool waits after a response is received from the DUT. Should be enough for the DUT to get ready to the next request");
            this.tbSafetyDelay.Validating += new CancelEventHandler(this.tbSafetyDelay_Validating);
            this.lblSafetyDelay.AutoSize = true;
            this.lblSafetyDelay.Location = new Point(6, 0x77);
            this.lblSafetyDelay.Name = "lblSafetyDelay";
            this.lblSafetyDelay.Size = new Size(0x94, 13);
            this.lblSafetyDelay.TabIndex = 0x1f;
            this.lblSafetyDelay.Text = "Time Between Requests (ms):";
            this.tbOperationDelay.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbOperationDelay.Location = new Point(0xa2, 0x5c);
            this.tbOperationDelay.MaximumSize = new Size(0x112, 20);
            this.tbOperationDelay.Name = "tbOperationDelay";
            this.tbOperationDelay.Size = new Size(0xe8, 20);
            this.tbOperationDelay.TabIndex = 30;
            this.toolTipSettings.SetToolTip(this.tbOperationDelay, "Delay for potentially time-consuming operation (like PTZ move)");
            this.tbOperationDelay.Validating += new CancelEventHandler(this.tbOperationDelay_Validating);
            this.lblTimeBetweenTests.AutoSize = true;
            this.lblTimeBetweenTests.Location = new Point(6, 70);
            this.lblTimeBetweenTests.Name = "lblTimeBetweenTests";
            this.lblTimeBetweenTests.Size = new Size(0x81, 13);
            this.lblTimeBetweenTests.TabIndex = 0x13;
            this.lblTimeBetweenTests.Text = "Time Between Tests (ms):";
            this.lblOperationDelay.AutoSize = true;
            this.lblOperationDelay.Location = new Point(6, 0x5f);
            this.lblOperationDelay.Name = "lblOperationDelay";
            this.lblOperationDelay.Size = new Size(0x6c, 13);
            this.lblOperationDelay.TabIndex = 0x1d;
            this.lblOperationDelay.Text = "Operation Delay (ms):";
            this.tbTimeBetweenTests.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbTimeBetweenTests.Location = new Point(0xa2, 0x43);
            this.tbTimeBetweenTests.MaximumSize = new Size(0x112, 20);
            this.tbTimeBetweenTests.Name = "tbTimeBetweenTests";
            this.tbTimeBetweenTests.Size = new Size(0xe8, 20);
            this.tbTimeBetweenTests.TabIndex = 11;
            this.toolTipSettings.SetToolTip(this.tbTimeBetweenTests, "Amount of time the Tool waits between test cases");
            this.tbTimeBetweenTests.Validating += new CancelEventHandler(this.tbTimeBetweenTests_Validating);
            this.lblRebootTime.AutoSize = true;
            this.lblRebootTime.Location = new Point(6, 0x2c);
            this.lblRebootTime.Name = "lblRebootTime";
            this.lblRebootTime.Size = new Size(0x6c, 13);
            this.lblRebootTime.TabIndex = 0x11;
            this.lblRebootTime.Text = "Reboot Timeout (ms):";
            this.tbRebootTimeout.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbRebootTimeout.Location = new Point(0xa2, 0x29);
            this.tbRebootTimeout.MaximumSize = new Size(0x112, 20);
            this.tbRebootTimeout.Name = "tbRebootTimeout";
            this.tbRebootTimeout.Size = new Size(0xe8, 20);
            this.tbRebootTimeout.TabIndex = 10;
            this.toolTipSettings.SetToolTip(this.tbRebootTimeout, "Amount of time enough to reboot");
            this.tbRebootTimeout.Validating += new CancelEventHandler(this.tbRebootTimeout_Validating);
            this.lblMessageTimeout.AutoSize = true;
            this.lblMessageTimeout.Location = new Point(6, 20);
            this.lblMessageTimeout.Name = "lblMessageTimeout";
            this.lblMessageTimeout.Size = new Size(0x74, 13);
            this.lblMessageTimeout.TabIndex = 15;
            this.lblMessageTimeout.Text = "Message Timeout (ms):";
            this.tbMessageTimeout.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbMessageTimeout.Location = new Point(0xa2, 15);
            this.tbMessageTimeout.MaximumSize = new Size(0x112, 20);
            this.tbMessageTimeout.Name = "tbMessageTimeout";
            this.tbMessageTimeout.Size = new Size(230, 20);
            this.tbMessageTimeout.TabIndex = 9;
            this.toolTipSettings.SetToolTip(this.tbMessageTimeout, "Time which the Tool waits for the DUT's response");
            this.tbMessageTimeout.Validating += new CancelEventHandler(this.tbMessageTimeout_Validating);
            this.gbEnvironment.Controls.Add(this.lblGatewayIpv6);
            this.gbEnvironment.Controls.Add(this.lblGatewayIpv4);
            this.gbEnvironment.Controls.Add(this.tbGatewayIpv6);
            this.gbEnvironment.Controls.Add(this.tbGatewayIpv4);
            this.gbEnvironment.Controls.Add(this.lblGateWay);
            this.gbEnvironment.Controls.Add(this.lblNtpIpv6);
            this.gbEnvironment.Controls.Add(this.lblDnsIpv6);
            this.gbEnvironment.Controls.Add(this.lblNtpIpv4);
            this.gbEnvironment.Controls.Add(this.lblDnsIpv4);
            this.gbEnvironment.Controls.Add(this.tbNtpIp6);
            this.gbEnvironment.Controls.Add(this.tbDnsIp6);
            this.gbEnvironment.Controls.Add(this.tbNtpIp4);
            this.gbEnvironment.Controls.Add(this.tbDnsIp4);
            this.gbEnvironment.Controls.Add(this.lblNTP);
            this.gbEnvironment.Controls.Add(this.lblDNS);
            this.gbEnvironment.Dock = DockStyle.Top;
            this.gbEnvironment.Location = new Point(0, 0x93);
            this.gbEnvironment.Name = "gbEnvironment";
            this.gbEnvironment.Size = new Size(410, 0x67);
            this.gbEnvironment.TabIndex = 8;
            this.gbEnvironment.TabStop = false;
            this.gbEnvironment.Text = "Environment";
            this.lblGatewayIpv6.AutoSize = true;
            this.lblGatewayIpv6.Location = new Point(0xe1, 0x4b);
            this.lblGatewayIpv6.Name = "lblGatewayIpv6";
            this.lblGatewayIpv6.Size = new Size(0x20, 13);
            this.lblGatewayIpv6.TabIndex = 0x15;
            this.lblGatewayIpv6.Text = "IPv6:";
            this.lblGatewayIpv4.AutoSize = true;
            this.lblGatewayIpv4.Location = new Point(0x2a, 0x4b);
            this.lblGatewayIpv4.Name = "lblGatewayIpv4";
            this.lblGatewayIpv4.Size = new Size(0x20, 13);
            this.lblGatewayIpv4.TabIndex = 20;
            this.lblGatewayIpv4.Text = "IPv4:";
            this.tbGatewayIpv6.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbGatewayIpv6.Location = new Point(0x107, 0x48);
            this.tbGatewayIpv6.MaximumSize = new Size(150, 20);
            this.tbGatewayIpv6.Name = "tbGatewayIpv6";
            this.tbGatewayIpv6.Size = new Size(130, 20);
            this.tbGatewayIpv6.TabIndex = 15;
            this.toolTipSettings.SetToolTip(this.tbGatewayIpv6, "Default gateway to be set during the testing (IPv4)");
            this.tbGatewayIpv6.Validating += new CancelEventHandler(this.tbGatewayIpv6_Validating);
            this.tbGatewayIpv4.Location = new Point(0x59, 0x48);
            this.tbGatewayIpv4.Name = "tbGatewayIpv4";
            this.tbGatewayIpv4.Size = new Size(130, 20);
            this.tbGatewayIpv4.TabIndex = 14;
            this.toolTipSettings.SetToolTip(this.tbGatewayIpv4, "Default gateway to be set during the testing (IPv4)");
            this.tbGatewayIpv4.Validating += new CancelEventHandler(this.tbGatewayIpv4_Validating);
            this.lblGateWay.AutoSize = true;
            this.lblGateWay.Location = new Point(6, 0x4b);
            this.lblGateWay.Name = "lblGateWay";
            this.lblGateWay.Size = new Size(0x1a, 13);
            this.lblGateWay.TabIndex = 0x11;
            this.lblGateWay.Text = "GW";
            this.lblNtpIpv6.AutoSize = true;
            this.lblNtpIpv6.Location = new Point(0xe1, 0x30);
            this.lblNtpIpv6.Name = "lblNtpIpv6";
            this.lblNtpIpv6.Size = new Size(0x20, 13);
            this.lblNtpIpv6.TabIndex = 0x10;
            this.lblNtpIpv6.Text = "IPv6:";
            this.lblDnsIpv6.AutoSize = true;
            this.lblDnsIpv6.Location = new Point(0xe1, 0x16);
            this.lblDnsIpv6.Name = "lblDnsIpv6";
            this.lblDnsIpv6.Size = new Size(0x20, 13);
            this.lblDnsIpv6.TabIndex = 15;
            this.lblDnsIpv6.Text = "IPv6:";
            this.lblNtpIpv4.AutoSize = true;
            this.lblNtpIpv4.Location = new Point(0x2a, 0x30);
            this.lblNtpIpv4.Name = "lblNtpIpv4";
            this.lblNtpIpv4.Size = new Size(0x20, 13);
            this.lblNtpIpv4.TabIndex = 14;
            this.lblNtpIpv4.Text = "IPv4:";
            this.lblDnsIpv4.AutoSize = true;
            this.lblDnsIpv4.Location = new Point(0x2a, 0x16);
            this.lblDnsIpv4.Name = "lblDnsIpv4";
            this.lblDnsIpv4.Size = new Size(0x20, 13);
            this.lblDnsIpv4.TabIndex = 7;
            this.lblDnsIpv4.Text = "IPv4:";
            this.tbNtpIp6.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbNtpIp6.Location = new Point(0x107, 0x2d);
            this.tbNtpIp6.MaximumSize = new Size(150, 20);
            this.tbNtpIp6.Name = "tbNtpIp6";
            this.tbNtpIp6.Size = new Size(130, 20);
            this.tbNtpIp6.TabIndex = 13;
            this.toolTipSettings.SetToolTip(this.tbNtpIp6, "NTP server address to be set during the testing (IPv6)");
            this.tbNtpIp6.Validating += new CancelEventHandler(this.tbNtpIp6_Validating);
            this.tbDnsIp6.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbDnsIp6.Location = new Point(0x107, 0x13);
            this.tbDnsIp6.MaximumSize = new Size(150, 20);
            this.tbDnsIp6.Name = "tbDnsIp6";
            this.tbDnsIp6.Size = new Size(130, 20);
            this.tbDnsIp6.TabIndex = 11;
            this.toolTipSettings.SetToolTip(this.tbDnsIp6, "DNS address to be set during the testing (IPv6)");
            this.tbDnsIp6.Validating += new CancelEventHandler(this.tbDnsIp6_Validating);
            this.tbNtpIp4.Location = new Point(0x59, 0x2d);
            this.tbNtpIp4.Name = "tbNtpIp4";
            this.tbNtpIp4.Size = new Size(130, 20);
            this.tbNtpIp4.TabIndex = 12;
            this.toolTipSettings.SetToolTip(this.tbNtpIp4, "NTP server address to be set during the testing (IPv4)");
            this.tbNtpIp4.Validating += new CancelEventHandler(this.tbNtpIp4_Validating);
            this.tbDnsIp4.Location = new Point(0x59, 0x13);
            this.tbDnsIp4.Name = "tbDnsIp4";
            this.tbDnsIp4.Size = new Size(130, 20);
            this.tbDnsIp4.TabIndex = 10;
            this.toolTipSettings.SetToolTip(this.tbDnsIp4, "DNS address to be set during the testing (IPv4)");
            this.tbDnsIp4.Validating += new CancelEventHandler(this.tbDnsIp4_Validating);
            this.lblNTP.AutoSize = true;
            this.lblNTP.Location = new Point(6, 0x30);
            this.lblNTP.Name = "lblNTP";
            this.lblNTP.Size = new Size(0x1d, 13);
            this.lblNTP.TabIndex = 1;
            this.lblNTP.Text = "NTP";
            this.lblDNS.AutoSize = true;
            this.lblDNS.Location = new Point(6, 0x16);
            this.lblDNS.Name = "lblDNS";
            this.lblDNS.Size = new Size(30, 13);
            this.lblDNS.TabIndex = 0;
            this.lblDNS.Text = "DNS";
            this.btnGetPTZNodes.Location = new Point(0x12b, 9);
            this.btnGetPTZNodes.Name = "btnGetPTZNodes";
            this.btnGetPTZNodes.Size = new Size(0x58, 0x17);
            this.btnGetPTZNodes.TabIndex = 0x1f;
            this.btnGetPTZNodes.Text = "Get";
            this.btnGetPTZNodes.UseVisualStyleBackColor = true;
            this.btnGetPTZNodes.Click += new EventHandler(this.btnGetPTZNodes_Click);
            this.lblPtzNode.AutoSize = true;
            this.lblPtzNode.Location = new Point(3, 14);
            this.lblPtzNode.Name = "lblPtzNode";
            this.lblPtzNode.Size = new Size(0x62, 13);
            this.lblPtzNode.TabIndex = 30;
            this.lblPtzNode.Text = "PTZ node for tests:";
            this.cmbPTZNodes.FormattingEnabled = true;
            this.cmbPTZNodes.Location = new Point(0x9a, 11);
            this.cmbPTZNodes.Name = "cmbPTZNodes";
            this.cmbPTZNodes.Size = new Size(0x73, 0x15);
            this.cmbPTZNodes.TabIndex = 0x1d;
            this.toolTipSettings.SetToolTip(this.cmbPTZNodes, "PTZ Node for testing. Whole list could be get by clicking \"Get\" button");
            this.lblPasswords.AutoSize = true;
            this.lblPasswords.Location = new Point(0x17, 0x37);
            this.lblPasswords.Name = "lblPasswords";
            this.lblPasswords.Size = new Size(0x3d, 13);
            this.lblPasswords.TabIndex = 0x1c;
            this.lblPasswords.Text = "Passwords:";
            this.rbOwnPasswords.AutoSize = true;
            this.rbOwnPasswords.Location = new Point(5, 0x1d);
            this.rbOwnPasswords.Name = "rbOwnPasswords";
            this.rbOwnPasswords.Size = new Size(0x89, 0x11);
            this.rbOwnPasswords.TabIndex = 0x13;
            this.rbOwnPasswords.TabStop = true;
            this.rbOwnPasswords.Text = "Provide own passwords";
            this.rbOwnPasswords.UseVisualStyleBackColor = true;
            this.tbPassword1.Location = new Point(90, 0x34);
            this.tbPassword1.Name = "tbPassword1";
            this.tbPassword1.Size = new Size(130, 20);
            this.tbPassword1.TabIndex = 20;
            this.toolTipSettings.SetToolTip(this.tbPassword1, "Password to be used when TestTool creates/updates users");
            this.rbEmbeddedPasswords.AutoSize = true;
            this.rbEmbeddedPasswords.Checked = true;
            this.rbEmbeddedPasswords.Location = new Point(5, 6);
            this.rbEmbeddedPasswords.Name = "rbEmbeddedPasswords";
            this.rbEmbeddedPasswords.Size = new Size(0xe5, 0x11);
            this.rbEmbeddedPasswords.TabIndex = 0x12;
            this.rbEmbeddedPasswords.TabStop = true;
            this.rbEmbeddedPasswords.Text = "Use embedded passwords for security tests";
            this.rbEmbeddedPasswords.UseVisualStyleBackColor = true;
            this.rbEmbeddedPasswords.CheckedChanged += new EventHandler(this.rbEmbeddedPasswords_CheckedChanged);
            this.tbPassword2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbPassword2.Location = new Point(0x100, 0x34);
            this.tbPassword2.MaximumSize = new Size(130, 20);
            this.tbPassword2.Name = "tbPassword2";
            this.tbPassword2.Size = new Size(0x81, 20);
            this.tbPassword2.TabIndex = 0x15;
            this.toolTipSettings.SetToolTip(this.tbPassword2, "Second password to be used when TestTool creates/updates users");
            this.cmbSecureMethod.DropDownStyle = ComboBoxStyle.DropDownList;
            this.cmbSecureMethod.FormattingEnabled = true;
            this.cmbSecureMethod.Location = new Point(0x9a, 0x4e);
            this.cmbSecureMethod.Name = "cmbSecureMethod";
            this.cmbSecureMethod.Size = new Size(0xe7, 0x15);
            this.cmbSecureMethod.TabIndex = 0x26;
            this.toolTipSettings.SetToolTip(this.cmbSecureMethod, "Method which requires user authentication to be used in security tests.");
            this.label2.AutoSize = true;
            this.label2.Location = new Point(3, 0x51);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x52, 13);
            this.label2.TabIndex = 0x25;
            this.label2.Text = "Secure method:";
            this.tbSubscriptionTimeout.Location = new Point(0x9b, 0x87);
            this.tbSubscriptionTimeout.Name = "tbSubscriptionTimeout";
            this.tbSubscriptionTimeout.Size = new Size(0x7d, 20);
            this.tbSubscriptionTimeout.TabIndex = 4;
            this.toolTipSettings.SetToolTip(this.tbSubscriptionTimeout, "Valid timeout for Subscribe operation");
            this.tbSubscriptionTimeout.Validating += new CancelEventHandler(this.tbSubscriptionTimeout_Validating);
            this.lblSubscriptionTimeout.AutoSize = true;
            this.lblSubscriptionTimeout.Location = new Point(3, 0x8a);
            this.lblSubscriptionTimeout.Name = "lblSubscriptionTimeout";
            this.lblSubscriptionTimeout.Size = new Size(0x7b, 13);
            this.lblSubscriptionTimeout.TabIndex = 0x23;
            this.lblSubscriptionTimeout.Text = "Subscription Timeout (s):";
            this.btnGetTopics.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnGetTopics.Location = new Point(0x12a, 0x26);
            this.btnGetTopics.Name = "btnGetTopics";
            this.btnGetTopics.Size = new Size(0x58, 0x17);
            this.btnGetTopics.TabIndex = 2;
            this.btnGetTopics.Text = "Get";
            this.btnGetTopics.UseVisualStyleBackColor = true;
            this.btnGetTopics.Click += new EventHandler(this.btnGetTopics_Click);
            this.cmbEventTopic.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.cmbEventTopic.FormattingEnabled = true;
            this.cmbEventTopic.Location = new Point(0x9a, 11);
            this.cmbEventTopic.Name = "cmbEventTopic";
            this.cmbEventTopic.Size = new Size(0xe8, 0x15);
            this.cmbEventTopic.TabIndex = 1;
            this.toolTipSettings.SetToolTip(this.cmbEventTopic, "Event topic to be used as filter in Event test cases. Can be selected or entered manually");
            this.cmbEventTopic.SelectedIndexChanged += new EventHandler(this.cmbEventTopic_SelectedIndexChanged);
            this.lblEventTopic.AutoSize = true;
            this.lblEventTopic.Location = new Point(3, 14);
            this.lblEventTopic.Name = "lblEventTopic";
            this.lblEventTopic.Size = new Size(0x3d, 13);
            this.lblEventTopic.TabIndex = 0x20;
            this.lblEventTopic.Text = "Event topic";
            this.gbMisc.Controls.Add(this.tcMiscSettings);
            this.gbMisc.Dock = DockStyle.Fill;
            this.gbMisc.Location = new Point(0, 250);
            this.gbMisc.Name = "gbMisc";
            this.gbMisc.Size = new Size(410, 290);
            this.gbMisc.TabIndex = 9;
            this.gbMisc.TabStop = false;
            this.gbMisc.Text = "Miscellaneous";
            this.tcMiscSettings.Controls.Add(this.tpSecurity);
            this.tcMiscSettings.Controls.Add(this.tpPTZ);
            this.tcMiscSettings.Controls.Add(this.tpEvents);
            this.tcMiscSettings.Controls.Add(this.tpIO);
            this.tcMiscSettings.Controls.Add(this.tpRecordingSearch);
            this.tcMiscSettings.Dock = DockStyle.Fill;
            this.tcMiscSettings.Location = new Point(3, 0x10);
            this.tcMiscSettings.Name = "tcMiscSettings";
            this.tcMiscSettings.SelectedIndex = 0;
            this.tcMiscSettings.Size = new Size(0x194, 0x10f);
            this.tcMiscSettings.TabIndex = 0x2a;
            this.tpSecurity.Controls.Add(this.rbEmbeddedPasswords);
            this.tpSecurity.Controls.Add(this.tbPassword1);
            this.tpSecurity.Controls.Add(this.lblPasswords);
            this.tpSecurity.Controls.Add(this.cmbSecureMethod);
            this.tpSecurity.Controls.Add(this.rbOwnPasswords);
            this.tpSecurity.Controls.Add(this.label2);
            this.tpSecurity.Controls.Add(this.tbPassword2);
            this.tpSecurity.Location = new Point(4, 0x16);
            this.tpSecurity.Name = "tpSecurity";
            this.tpSecurity.Padding = new Padding(3);
            this.tpSecurity.Size = new Size(0x18c, 0xf5);
            this.tpSecurity.TabIndex = 0;
            this.tpSecurity.Text = "Security";
            this.tpSecurity.ToolTipText = "Custom values for Security test cases";
            this.tpSecurity.UseVisualStyleBackColor = true;
            this.tpPTZ.Controls.Add(this.btnGetVideoSources);
            this.tpPTZ.Controls.Add(this.cmbVideoSource);
            this.tpPTZ.Controls.Add(this.lblVideoSource);
            this.tpPTZ.Controls.Add(this.btnGetPTZNodes);
            this.tpPTZ.Controls.Add(this.cmbPTZNodes);
            this.tpPTZ.Controls.Add(this.lblPtzNode);
            this.tpPTZ.Location = new Point(4, 0x16);
            this.tpPTZ.Name = "tpPTZ";
            this.tpPTZ.Padding = new Padding(3);
            this.tpPTZ.Size = new Size(0x18c, 0xf5);
            this.tpPTZ.TabIndex = 1;
            this.tpPTZ.Text = "PTZ";
            this.tpPTZ.ToolTipText = "Settings for performing PTZ tests";
            this.tpPTZ.UseVisualStyleBackColor = true;
            this.btnGetVideoSources.Location = new Point(0x12b, 0x26);
            this.btnGetVideoSources.Name = "btnGetVideoSources";
            this.btnGetVideoSources.Size = new Size(0x58, 0x17);
            this.btnGetVideoSources.TabIndex = 0x22;
            this.btnGetVideoSources.Text = "Get";
            this.btnGetVideoSources.UseVisualStyleBackColor = true;
            this.btnGetVideoSources.Visible = false;
            this.btnGetVideoSources.Click += new EventHandler(this.btnGetVideoSources_Click);
            this.cmbVideoSource.FormattingEnabled = true;
            this.cmbVideoSource.Location = new Point(0x9a, 40);
            this.cmbVideoSource.Name = "cmbVideoSource";
            this.cmbVideoSource.Size = new Size(0x73, 0x15);
            this.cmbVideoSource.TabIndex = 0x21;
            this.toolTipSettings.SetToolTip(this.cmbVideoSource, "Video source usedfor tests execution");
            this.cmbVideoSource.Visible = false;
            this.lblVideoSource.AutoSize = true;
            this.lblVideoSource.Location = new Point(3, 0x2b);
            this.lblVideoSource.Name = "lblVideoSource";
            this.lblVideoSource.Size = new Size(0x70, 13);
            this.lblVideoSource.TabIndex = 0x20;
            this.lblVideoSource.Text = "Video source for tests:";
            this.lblVideoSource.Visible = false;
            this.tpEvents.Controls.Add(this.lblEventTopic);
            this.tpEvents.Controls.Add(this.tbNamespaces);
            this.tpEvents.Controls.Add(this.btnGetTopics);
            this.tpEvents.Controls.Add(this.lblNamespaces);
            this.tpEvents.Controls.Add(this.cmbEventTopic);
            this.tpEvents.Controls.Add(this.tbSubscriptionTimeout);
            this.tpEvents.Controls.Add(this.lblSubscriptionTimeout);
            this.tpEvents.Location = new Point(4, 0x16);
            this.tpEvents.Name = "tpEvents";
            this.tpEvents.Padding = new Padding(3);
            this.tpEvents.Size = new Size(0x18c, 0xf5);
            this.tpEvents.TabIndex = 2;
            this.tpEvents.Text = "Events";
            this.tpEvents.ToolTipText = "Custom values for Events test cases";
            this.tpEvents.UseVisualStyleBackColor = true;
            this.tbNamespaces.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbNamespaces.Location = new Point(0x9a, 0x49);
            this.tbNamespaces.Multiline = true;
            this.tbNamespaces.Name = "tbNamespaces";
            this.tbNamespaces.ScrollBars = ScrollBars.Vertical;
            this.tbNamespaces.Size = new Size(0xe8, 0x38);
            this.tbNamespaces.TabIndex = 3;
            this.toolTipSettings.SetToolTip(this.tbNamespaces, "Namespaces definition for the Event Topic above");
            this.tbNamespaces.Leave += new EventHandler(this.tbNamespaces_Leave);
            this.lblNamespaces.AutoSize = true;
            this.lblNamespaces.Location = new Point(3, 0x49);
            this.lblNamespaces.Name = "lblNamespaces";
            this.lblNamespaces.Size = new Size(0x61, 13);
            this.lblNamespaces.TabIndex = 0x27;
            this.lblNamespaces.Text = "Topic namespaces";
            this.tpIO.Controls.Add(this.tbRelayOutputsDelayMonostable);
            this.tpIO.Controls.Add(this.lblRelayOutputsDelay);
            this.tpIO.Location = new Point(4, 0x16);
            this.tpIO.Name = "tpIO";
            this.tpIO.Padding = new Padding(3);
            this.tpIO.Size = new Size(0x18c, 0xf5);
            this.tpIO.TabIndex = 3;
            this.tpIO.Text = "I/O";
            this.tpIO.UseVisualStyleBackColor = true;
            this.tbRelayOutputsDelayMonostable.Location = new Point(150, 11);
            this.tbRelayOutputsDelayMonostable.Name = "tbRelayOutputsDelayMonostable";
            this.tbRelayOutputsDelayMonostable.Size = new Size(0x71, 20);
            this.tbRelayOutputsDelayMonostable.TabIndex = 0x2d;
            this.tbRelayOutputsDelayMonostable.Validating += new CancelEventHandler(this.tbRelayOutputDelayTimeMonostable_Validating);
            this.lblRelayOutputsDelay.AutoSize = true;
            this.lblRelayOutputsDelay.Location = new Point(3, 14);
            this.lblRelayOutputsDelay.Name = "lblRelayOutputsDelay";
            this.lblRelayOutputsDelay.Size = new Size(0x8b, 13);
            this.lblRelayOutputsDelay.TabIndex = 0x2c;
            this.lblRelayOutputsDelay.Text = "Relay outputs delay time (s):";
            this.tpRecordingSearch.Controls.Add(this.tbRetentionTime);
            this.tpRecordingSearch.Controls.Add(this.lblRetentionTimeout);
            this.tpRecordingSearch.Controls.Add(this.btnValidate);
            this.tpRecordingSearch.Controls.Add(this.tbMetadataFilter);
            this.tpRecordingSearch.Controls.Add(this.lblMetadataFilter);
            this.tpRecordingSearch.Controls.Add(this.tbTimeout);
            this.tpRecordingSearch.Controls.Add(this.btnGetRecordings);
            this.tpRecordingSearch.Controls.Add(this.cmbRecordingToken);
            this.tpRecordingSearch.Controls.Add(this.lblRecordingToken);
            this.tpRecordingSearch.Controls.Add(this.lblQueryTimeout);
            this.tpRecordingSearch.Location = new Point(4, 0x16);
            this.tpRecordingSearch.Name = "tpRecordingSearch";
            this.tpRecordingSearch.Padding = new Padding(3);
            this.tpRecordingSearch.Size = new Size(0x18c, 0xf5);
            this.tpRecordingSearch.TabIndex = 4;
            this.tpRecordingSearch.Text = "Recording";
            this.tpRecordingSearch.UseVisualStyleBackColor = true;
            this.tbRetentionTime.Location = new Point(0x9b, 0xab);
            this.tbRetentionTime.Name = "tbRetentionTime";
            this.tbRetentionTime.Size = new Size(0x71, 20);
            this.tbRetentionTime.TabIndex = 15;
            this.lblRetentionTimeout.AutoSize = true;
            this.lblRetentionTimeout.Location = new Point(8, 0xae);
            this.lblRetentionTimeout.Name = "lblRetentionTimeout";
            this.lblRetentionTimeout.Size = new Size(0x81, 13);
            this.lblRetentionTimeout.TabIndex = 0x30;
            this.lblRetentionTimeout.Text = "Retention Time (duration):";
            this.btnValidate.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            this.btnValidate.Location = new Point(0x12d, 0x85);
            this.btnValidate.Name = "btnValidate";
            this.btnValidate.Size = new Size(0x55, 0x17);
            this.btnValidate.TabIndex = 14;
            this.btnValidate.Text = "Validate";
            this.btnValidate.UseVisualStyleBackColor = true;
            this.btnValidate.Click += new EventHandler(this.btnValidate_Click);
            this.tbMetadataFilter.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.tbMetadataFilter.Location = new Point(0x9a, 0x43);
            this.tbMetadataFilter.Name = "tbMetadataFilter";
            this.tbMetadataFilter.Size = new Size(230, 60);
            this.tbMetadataFilter.TabIndex = 13;
            this.tbMetadataFilter.Text = "";
            this.tbMetadataFilter.TextChanged += new EventHandler(this.tbMetadataFilter_TextChanged);
            this.lblMetadataFilter.AutoSize = true;
            this.lblMetadataFilter.Location = new Point(6, 70);
            this.lblMetadataFilter.Name = "lblMetadataFilter";
            this.lblMetadataFilter.Size = new Size(80, 13);
            this.lblMetadataFilter.TabIndex = 0x2a;
            this.lblMetadataFilter.Text = "Metadata Filter:";
            this.tbTimeout.Location = new Point(0x9a, 0x27);
            this.tbTimeout.Name = "tbTimeout";
            this.tbTimeout.Size = new Size(0x73, 20);
            this.tbTimeout.TabIndex = 12;
            this.tbTimeout.Validating += new CancelEventHandler(this.tbTimeout_Validating);
            this.btnGetRecordings.Location = new Point(0x12b, 9);
            this.btnGetRecordings.Name = "btnGetRecordings";
            this.btnGetRecordings.Size = new Size(0x58, 0x17);
            this.btnGetRecordings.TabIndex = 11;
            this.btnGetRecordings.Text = "Get";
            this.btnGetRecordings.UseVisualStyleBackColor = true;
            this.btnGetRecordings.Click += new EventHandler(this.btnGetRecordings_Click);
            this.cmbRecordingToken.FormattingEnabled = true;
            this.cmbRecordingToken.Location = new Point(0x9a, 11);
            this.cmbRecordingToken.Name = "cmbRecordingToken";
            this.cmbRecordingToken.Size = new Size(0x73, 0x15);
            this.cmbRecordingToken.TabIndex = 10;
            this.toolTipSettings.SetToolTip(this.cmbRecordingToken, "Recording used for tests execution");
            this.lblRecordingToken.AutoSize = true;
            this.lblRecordingToken.Location = new Point(6, 14);
            this.lblRecordingToken.Name = "lblRecordingToken";
            this.lblRecordingToken.Size = new Size(0x63, 13);
            this.lblRecordingToken.TabIndex = 0x26;
            this.lblRecordingToken.Text = "Recording for tests:";
            this.lblQueryTimeout.AutoSize = true;
            this.lblQueryTimeout.Location = new Point(6, 0x2a);
            this.lblQueryTimeout.Name = "lblQueryTimeout";
            this.lblQueryTimeout.Size = new Size(0x91, 13);
            this.lblQueryTimeout.TabIndex = 0x24;
            this.lblQueryTimeout.Text = "Timeout for getting results (s):";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.gbMisc);
            base.Controls.Add(this.gbEnvironment);
            base.Controls.Add(this.gbTimeouts);
            base.Name = "SettingsControl";
            base.Size = new Size(410, 540);
            this.gbTimeouts.ResumeLayout(false);
            this.gbTimeouts.PerformLayout();
            this.gbEnvironment.ResumeLayout(false);
            this.gbEnvironment.PerformLayout();
            this.gbMisc.ResumeLayout(false);
            this.tcMiscSettings.ResumeLayout(false);
            this.tpSecurity.ResumeLayout(false);
            this.tpSecurity.PerformLayout();
            this.tpPTZ.ResumeLayout(false);
            this.tpPTZ.PerformLayout();
            this.tpEvents.ResumeLayout(false);
            this.tpEvents.PerformLayout();
            this.tpIO.ResumeLayout(false);
            this.tpIO.PerformLayout();
            this.tpRecordingSearch.ResumeLayout(false);
            this.tpRecordingSearch.PerformLayout();
            base.ResumeLayout(false);
        }

        private void rbEmbeddedPasswords_CheckedChanged(object sender, EventArgs e)
        {
            this.rbEmbeddedPasswords.TabStop = true;
            this.rbOwnPasswords.TabStop = true;
            this.EnablePasswords(this._currentState);
            if (this.rbEmbeddedPasswords.Checked)
            {
                this._password1 = this.tbPassword1.Text;
                this._password2 = this.tbPassword2.Text;
                this.tbPassword1.Text = "OnvifTest123";
                this.tbPassword2.Text = "OnvifTest321";
            }
            else
            {
                this.tbPassword1.Text = this._password1;
                this.tbPassword2.Text = this._password2;
            }
        }

        public void SetCurrentState(TestTool.GUI.Enums.ApplicationState state)
        {
            this._currentState = state;
        }

        public void SetEventsTopic(List<EventsTopicInfo> topics)
        {
            base.Invoke((Action)delegate
            {
                this.cmbEventTopic.DisplayMember = "Topic";
                this.cmbEventTopic.DataSource = topics;
            });
        }

        public void SetPTZNodes(PTZNode[] nodes)
        {
            base.Invoke((Action)delegate
            {
                string text = this.cmbPTZNodes.Text;
                this.cmbPTZNodes.Items.Clear();
                foreach (PTZNode node in nodes)
                {
                    this.cmbPTZNodes.Items.Add(node.token);
                }
                if (this.cmbPTZNodes.Items.Count > 0)
                {
                    if (this.cmbPTZNodes.Items.Contains(text))
                    {
                        this.cmbPTZNodes.SelectedItem = text;
                    }
                    else
                    {
                        this.cmbPTZNodes.SelectedIndex = 0;
                    }
                }
            });
        }

        public void SetRecordings(IEnumerable<string> recordings)
        {
            base.Invoke((Action)delegate
            {
                foreach (ComboBox box in new ComboBox[] { this.cmbRecordingToken })
                {
                    string text = box.Text;
                    box.Items.Clear();
                    foreach (string str2 in recordings)
                    {
                        box.Items.Add(str2);
                    }
                    if (box.Items.Count > 0)
                    {
                        if (box.Items.Contains(text))
                        {
                            box.SelectedItem = text;
                        }
                        else
                        {
                            box.SelectedIndex = 0;
                        }
                    }
                }
            });
        }

        public void SetSecureMethods(IEnumerable<string> methods)
        {
            this.cmbSecureMethod.DataSource = methods;
        }

        public void SetVideoSources(VideoSource[] sources)
        {
            base.Invoke((Action)delegate
            {
                string text = this.cmbVideoSource.Text;
                this.cmbVideoSource.Items.Clear();
                foreach (VideoSource source in sources)
                {
                    this.cmbVideoSource.Items.Add(source.token);
                }
                if (this.cmbVideoSource.Items.Count > 0)
                {
                    if (this.cmbVideoSource.Items.Contains(text))
                    {
                        this.cmbVideoSource.SelectedItem = text;
                    }
                    else
                    {
                        this.cmbVideoSource.SelectedIndex = 0;
                    }
                }
            });
        }

        public void ShowMissingSettings(string name)
        {
            string str;
            if (((str = name) != null) && (str == "EventTopic"))
            {
                this.tcMiscSettings.SelectedTab = this.tpEvents;
                if (string.IsNullOrEmpty(this.cmbEventTopic.Text))
                {
                    this.cmbEventTopic.Focus();
                }
                else if (string.IsNullOrEmpty(this.tbNamespaces.Text))
                {
                    this.tbNamespaces.Focus();
                }
            }
        }

        public override void SwitchToState(TestTool.GUI.Enums.ApplicationState state)
        {
            this.SetCurrentState(state);
        }

        private void tbDnsIp4_Validating(object sender, CancelEventArgs e)
        {
            System.Net.IPAddress address;
            bool flag = System.Net.IPAddress.TryParse(this.tbDnsIp4.Text, out address);
            if (flag)
            {
                flag = address.AddressFamily == AddressFamily.InterNetwork;
            }
            if (!flag)
            {
                this.tbDnsIp4.Text = this._lastValidIpv4Dns;
            }
            else
            {
                this._lastValidIpv4Dns = this.tbDnsIp4.Text;
            }
        }

        private void tbDnsIp6_Validating(object sender, CancelEventArgs e)
        {
            System.Net.IPAddress address;
            bool flag = System.Net.IPAddress.TryParse(this.tbDnsIp6.Text, out address);
            if (flag)
            {
                flag = address.AddressFamily == AddressFamily.InterNetworkV6;
            }
            if (!flag)
            {
                this.tbDnsIp6.Text = this._lastValidIpv6Dns;
            }
            else
            {
                this._lastValidIpv6Dns = this.tbDnsIp6.Text;
            }
        }

        private void tbGatewayIpv4_Validating(object sender, CancelEventArgs e)
        {
            System.Net.IPAddress address;
            bool flag = System.Net.IPAddress.TryParse(this.tbGatewayIpv4.Text, out address);
            if (flag)
            {
                flag = address.AddressFamily == AddressFamily.InterNetwork;
            }
            if (!flag)
            {
                this.tbGatewayIpv4.Text = this._lastValidIpv4Gateway;
            }
            else
            {
                this._lastValidIpv4Gateway = this.tbGatewayIpv4.Text;
            }
        }

        private void tbGatewayIpv6_Validating(object sender, CancelEventArgs e)
        {
            System.Net.IPAddress address;
            bool flag = System.Net.IPAddress.TryParse(this.tbGatewayIpv6.Text, out address);
            if (flag)
            {
                flag = address.AddressFamily == AddressFamily.InterNetworkV6;
            }
            if (!flag)
            {
                this.tbGatewayIpv6.Text = this._lastValidIpv6Gateway;
            }
            else
            {
                this._lastValidIpv6Gateway = this.tbGatewayIpv6.Text;
            }
        }

        private void tbMessageTimeout_Validating(object sender, CancelEventArgs e)
        {
            int result = -1;
            bool flag = int.TryParse(this.tbMessageTimeout.Text, out result);
            if (flag)
            {
                flag = result > 0;
            }
            if (!flag)
            {
                this.tbMessageTimeout.Text = this._lastValidMessageTimeout.ToString();
            }
            else
            {
                this._lastValidMessageTimeout = result;
            }
        }

        private void tbMetadataFilter_TextChanged(object sender, EventArgs e)
        {
            if (!this._isTextChangedHandlerRunning)
            {
                this._isTextChangedHandlerRunning = true;
                int selectionStart = this.tbMetadataFilter.SelectionStart;
                int selectionLength = this.tbMetadataFilter.SelectionLength;
                this.tbMetadataFilter.SelectAll();
                this.tbMetadataFilter.SelectionBackColor = SystemColors.Window;
                this.tbMetadataFilter.SelectionStart = selectionStart;
                this.tbMetadataFilter.SelectionLength = selectionLength;
                this._isTextChangedHandlerRunning = false;
            }
        }

        private void tbNamespaces_Leave(object sender, EventArgs e)
        {
            string[] strArray = this.tbNamespaces.Text.Replace(Environment.NewLine, "").Split(new char[] { ' ' });
            bool flag = true;
            foreach (string str in strArray)
            {
                if (!string.IsNullOrEmpty(str) && !str.Contains("="))
                {
                    flag = false;
                }
            }
            if (!flag)
            {
                this.ShowError("Namespaces definition is incorrect. Should be in form \"prefix1=\"namespace1\"[ prefix2=\"namespace2\"]\" ");
            }
        }

        private void tbNtpIp4_Validating(object sender, CancelEventArgs e)
        {
            System.Net.IPAddress address;
            bool flag = System.Net.IPAddress.TryParse(this.tbNtpIp4.Text, out address);
            if (flag)
            {
                flag = address.AddressFamily == AddressFamily.InterNetwork;
            }
            if (!flag)
            {
                this.tbNtpIp4.Text = this._lastValidIpv4Ntp;
            }
            else
            {
                this._lastValidIpv4Ntp = this.tbDnsIp4.Text;
            }
        }

        private void tbNtpIp6_Validating(object sender, CancelEventArgs e)
        {
            System.Net.IPAddress address;
            bool flag = System.Net.IPAddress.TryParse(this.tbNtpIp6.Text, out address);
            if (flag)
            {
                flag = address.AddressFamily == AddressFamily.InterNetworkV6;
            }
            if (!flag)
            {
                this.tbNtpIp6.Text = this._lastValidIpv6Ntp;
            }
            else
            {
                this._lastValidIpv6Ntp = this.tbDnsIp6.Text;
            }
        }

        private void tbOperationDelay_Validating(object sender, CancelEventArgs e)
        {
            int result = 0;
            bool flag = int.TryParse(this.tbOperationDelay.Text, out result);
            if (flag)
            {
                flag = result >= 0;
            }
            if (!flag)
            {
                this.tbOperationDelay.Text = this._lastValidOperationDelay.ToString();
            }
            else
            {
                this._lastValidOperationDelay = result;
            }
        }

        private void tbRebootTimeout_Validating(object sender, CancelEventArgs e)
        {
            int result = -1;
            bool flag = int.TryParse(this.tbRebootTimeout.Text, out result);
            if (flag)
            {
                flag = result > 0;
            }
            if (!flag)
            {
                this.tbRebootTimeout.Text = this._lastValidRebootTimeout.ToString();
            }
            else
            {
                this._lastValidRebootTimeout = result;
            }
        }

        private void tbRelayOutputDelayTimeMonostable_Validating(object sender, CancelEventArgs e)
        {
            int result = 0;
            bool flag = int.TryParse(this.tbRelayOutputsDelayMonostable.Text, out result);
            if (flag)
            {
                flag = result > 0;
            }
            if (!flag)
            {
                this.tbRelayOutputsDelayMonostable.Text = this._lastValidRelayOutputDelayMonostable.ToString();
            }
            else
            {
                this._lastValidRelayOutputDelayMonostable = result;
            }
        }

        private void tbSafetyDelay_Validating(object sender, CancelEventArgs e)
        {
            int result = 0;
            bool flag = int.TryParse(this.tbSafetyDelay.Text, out result);
            if (flag)
            {
                flag = result >= 0;
            }
            if (!flag)
            {
                this.tbSafetyDelay.Text = this._lastValidSafetyDelay.ToString();
            }
            else
            {
                this._lastValidSafetyDelay = result;
            }
        }

        private void tbSubscriptionTimeout_Validating(object sender, CancelEventArgs e)
        {
            int result = 0;
            bool flag = int.TryParse(this.tbSubscriptionTimeout.Text, out result);
            if (flag)
            {
                flag = result > 0;
            }
            if (!flag)
            {
                this.tbSubscriptionTimeout.Text = this._lastValidSubscriptionTimeout.ToString();
            }
            else
            {
                this._lastValidSubscriptionTimeout = result;
            }
        }

        private void tbTimeBetweenTests_Validating(object sender, CancelEventArgs e)
        {
            int result = -1;
            bool flag = int.TryParse(this.tbTimeBetweenTests.Text, out result);
            if (flag)
            {
                flag = result > 0;
            }
            if (!flag)
            {
                this.tbTimeBetweenTests.Text = this._lastValidTimeBetweenTests.ToString();
            }
            else
            {
                this._lastValidTimeBetweenTests = result;
            }
        }

        private void tbTimeout_Validating(object sender, CancelEventArgs e)
        {
            int result = 0;
            bool flag = int.TryParse(this.tbTimeout.Text, out result);
            if (flag)
            {
                flag = result > 0;
            }
            if (!flag)
            {
                this.tbTimeout.Text = this._lastValidSearchTimeout.ToString();
            }
            else
            {
                this._lastValidSearchTimeout = result;
            }
        }

        public List<object> AdvancedSettings
        {
            get
            {
                List<object> list = new List<object>();
                if (this._pages != null)
                {
                    foreach (SettingsTabPage page in this._pages.Values)
                    {
                        list.Add(page.Parameters);
                    }
                }
                return list;
            }
            set
            {
                if (value != null)
                {
                    foreach (object obj2 in value)
                    {
                        string key = obj2.GetType().GUID.ToString();
                        if (this._pages.ContainsKey(key))
                        {
                            this._pages[key].Parameters = obj2;
                        }
                    }
                }
                else
                {
                    foreach (SettingsTabPage page in this._pages.Values)
                    {
                        page.Clear();
                    }
                }
            }
        }

        private Control[] ControlsList
        {
            get
            {
                if (this._controlsList == null)
                {
                    this._controlsList = new Control[] {
                        this.tbMessageTimeout, this.tbRebootTimeout, this.tbTimeBetweenTests, this.tbDnsIp4, this.tbNtpIp4, this.tbGatewayIpv4, this.tbDnsIp6, this.tbNtpIp6, this.tbGatewayIpv6, this.cmbPTZNodes, this.btnGetPTZNodes, this.rbEmbeddedPasswords, this.rbOwnPasswords, this.tbPassword1, this.tbPassword2, this.tbOperationDelay,
                        this.tbSafetyDelay, this.cmbSecureMethod, this.cmbEventTopic, this.cmbVideoSource, this.tbRelayOutputsDelayMonostable, this.btnGetTopics, this.btnGetVideoSources, this.tbSubscriptionTimeout, this.tbNamespaces, this.tbTimeout, this.cmbRecordingToken, this.tbRetentionTime
                     };
                }
                return this._controlsList;
            }
        }

        public string DnsIpv4
        {
            get
            {
                return this.tbDnsIp4.Text;
            }
            set
            {
                this.tbDnsIp4.Text = value;
                this._lastValidIpv4Dns = value;
            }
        }

        public string DnsIpv6
        {
            get
            {
                return this.tbDnsIp6.Text;
            }
            set
            {
                this.tbDnsIp6.Text = value;
                this._lastValidIpv6Dns = value;
            }
        }

        public string EventTopic
        {
            get
            {
                return this.cmbEventTopic.Text;
            }
            set
            {
                this.cmbEventTopic.Text = value;
            }
        }

        public string GatewayIpv4
        {
            get
            {
                return this.tbGatewayIpv4.Text;
            }
            set
            {
                this.tbGatewayIpv4.Text = value;
                this._lastValidIpv4Gateway = value;
            }
        }

        public string GatewayIpv6
        {
            get
            {
                return this.tbGatewayIpv6.Text;
            }
            set
            {
                this.tbGatewayIpv6.Text = value;
                this._lastValidIpv6Gateway = value;
            }
        }

        public int MessageTimeout
        {
            get
            {
                int result = 0;
                int.TryParse(this.tbMessageTimeout.Text, out result);
                return result;
            }
            set
            {
                this._lastValidMessageTimeout = value;
                this.tbMessageTimeout.Text = value.ToString();
            }
        }

        public string MetadataFilter
        {
            get
            {
                return this.tbMetadataFilter.Text;
            }
            set
            {
                this.tbMetadataFilter.Text = value;
            }
        }

        public string NtpIpv4
        {
            get
            {
                return this.tbNtpIp4.Text;
            }
            set
            {
                this.tbNtpIp4.Text = value;
                this._lastValidIpv4Ntp = value;
            }
        }

        public string NtpIpv6
        {
            get
            {
                return this.tbNtpIp6.Text;
            }
            set
            {
                this.tbNtpIp6.Text = value;
                this._lastValidIpv6Ntp = value;
            }
        }

        public int OperationDelay
        {
            get
            {
                int num;
                int.TryParse(this.tbOperationDelay.Text, out num);
                return num;
            }
            set
            {
                this._lastValidOperationDelay = value;
                this.tbOperationDelay.Text = value.ToString();
            }
        }

        public string Password1
        {
            get
            {
                return this.tbPassword1.Text;
            }
            set
            {
                this.tbPassword1.Text = value;
            }
        }

        public string Password2
        {
            get
            {
                return this.tbPassword2.Text;
            }
            set
            {
                this.tbPassword2.Text = value;
            }
        }

        public string PTZNodeToken
        {
            get
            {
                return this.cmbPTZNodes.Text;
            }
            set
            {
                if (!this.cmbPTZNodes.Items.Contains(value) && !string.IsNullOrEmpty(value))
                {
                    this.cmbPTZNodes.Items.Add(value);
                }
                this.cmbPTZNodes.Text = value;
            }
        }

        public int RebootTimeout
        {
            get
            {
                int result = 0;
                int.TryParse(this.tbRebootTimeout.Text, out result);
                return result;
            }
            set
            {
                this._lastValidRebootTimeout = value;
                this.tbRebootTimeout.Text = value.ToString();
            }
        }

        public string RecordingToken
        {
            get
            {
                return this.cmbRecordingToken.Text;
            }
            set
            {
                if (!this.cmbRecordingToken.Items.Contains(value) && !string.IsNullOrEmpty(value))
                {
                    this.cmbRecordingToken.Items.Add(value);
                }
                this.cmbRecordingToken.Text = value;
            }
        }

        public int RecoveryDelay
        {
            get
            {
                int num;
                int.TryParse(this.tbSafetyDelay.Text, out num);
                return num;
            }
            set
            {
                this._lastValidSafetyDelay = value;
                this.tbSafetyDelay.Text = value.ToString();
            }
        }

        public int RelayOutputDelayTimeMonostable
        {
            get
            {
                int num;
                int.TryParse(this.tbRelayOutputsDelayMonostable.Text, out num);
                return num;
            }
            set
            {
                this._lastValidRelayOutputDelayMonostable = value;
                this.tbRelayOutputsDelayMonostable.Text = value.ToString();
            }
        }

        public string RetentionTime
        {
            get
            {
                return this.tbRetentionTime.Text;
            }
            set
            {
                this.tbRetentionTime.Text = value;
            }
        }

        public int SearchTimeout
        {
            get
            {
                int num;
                int.TryParse(this.tbTimeout.Text, out num);
                return num;
            }
            set
            {
                this._lastValidSearchTimeout = value;
                this.tbTimeout.Text = value.ToString();
            }
        }

        public string SecureMethod
        {
            get
            {
                return this.cmbSecureMethod.Text;
            }
            set
            {
                this.cmbSecureMethod.Text = value;
            }
        }

        public int SubscriptionTimeout
        {
            get
            {
                int num;
                int.TryParse(this.tbSubscriptionTimeout.Text, out num);
                return num;
            }
            set
            {
                this._lastValidSubscriptionTimeout = value;
                this.tbSubscriptionTimeout.Text = value.ToString();
            }
        }

        public int TimeBetweenTests
        {
            get
            {
                int num;
                int.TryParse(this.tbTimeBetweenTests.Text, out num);
                return num;
            }
            set
            {
                this._lastValidTimeBetweenTests = value;
                this.tbTimeBetweenTests.Text = value.ToString();
            }
        }

        public string TopicNamespaces
        {
            get
            {
                return this.tbNamespaces.Text.TrimEnd(new char[0]);
            }
            set
            {
                this.tbNamespaces.Text = value;
            }
        }

        public bool UseEmbeddedPassword
        {
            get
            {
                return this.rbEmbeddedPasswords.Checked;
            }
            set
            {
                this.rbEmbeddedPasswords.Checked = value;
                this.rbOwnPasswords.Checked = !value;
                if (value)
                {
                    this.tbPassword1.Text = "OnvifTest123";
                    this.tbPassword2.Text = "OnvifTest321";
                }
                this.rbEmbeddedPasswords.TabStop = true;
                this.rbOwnPasswords.TabStop = true;
                this.EnablePasswords(this._currentState);
            }
        }

        public string VideoSourceToken
        {
            get
            {
                return this.cmbVideoSource.Text;
            }
            set
            {
                if (!this.cmbVideoSource.Items.Contains(value) && !string.IsNullOrEmpty(value))
                {
                    this.cmbVideoSource.Items.Add(value);
                }
                this.cmbVideoSource.Text = value;
            }
        }
    }
}

